<?php
/**
 * $files (array of File) files to show
 */
?>
<div id="fileList">
    <table id="dragTable">
        <?php for($i=0; $i<count($files); $i++):
            $file=$files[$i];
            $fileDir = $file->status==0 ? UploadWidget::$tempDir : UploadWidget::$fileDir;
        ?>
        <tr>
            <td width="16px" class="dragHandle" style="background: #ccc;"></td>
            <td>
                <a href="<?= UploadUtils::getUrl($fileDir)."/".$file->filename; ?>"
                   title="<?=$file->filename?> (<?=round($file->filesize/1024, 2)?> Kb)">
                    <?php if (UploadUtils::isImageFileMime($file->filemime)): ?>
                        <img height="50px" alt="<?=$file->filename?>"
                             src="<?= UploadUtils::getUrl($fileDir)."/".$file->filename; ?>"/>
                    <?php else: ?>
                        <?=$file->filename?>
                    <?php endif; ?>
                </a>
            </td>
            <td >
                <a class="delete" href="#"
                    <?=!empty($file->fid) ? 'fid="'.$file->fid.'"' : ' '?>
                       <?=!empty($file->sid) ? 'sid="'.$file->sid.'"' : ' '?> >
                           <?= Yii::t('amo', 'Delete'); ?>
                </a>
            </td>
            <td style="display:none;">
                <input type="hidden" name="File[<?=$i?>][fid]" value="<?= !empty($file->sid) ? "s".$file->sid : $file->fid; ?>"/>
                <input type="hidden" name="File[<?=$i?>][entity]" value="<?= $file->entity; ?>"/>
                <input type="hidden" name="File[<?=$i?>][EXid]" value="<?= $file->EXid; ?>"/>
                <input type="hidden" name="File[<?=$i?>][uid]" value="<?= $file->uid; ?>"/>
                <input type="hidden" name="File[<?=$i?>][filename]" value="<?= $file->filename; ?>"/>
                <input type="hidden" name="File[<?=$i?>][filemime]" value="<?= $file->filemime; ?>"/>
                <input type="hidden" name="File[<?=$i?>][filesize]" value="<?= $file->filesize; ?>"/>
                <input type="hidden" name="File[<?=$i?>][status]" value="<?= $file->status; ?>"/>
                <input type="hidden" name="File[<?=$i?>][weight]" class="weight" value="<?=$i?>"/>
            </td>
        </tr>
        <?php endfor; ?>
    </table>
</div>